<template>

  <!--选择处理人-->
  <el-dialog title="选择处理人" @close="closeDialog" :visible.sync="visibleDialog" width="60%">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="编辑ID" prop="userId">
        <el-input v-model="queryParams.userId" placeholder="请输入编辑ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="姓名" prop="nickName">
        <el-input v-model="queryParams.nickName" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="手机号" prop="phonenumber">
        <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="queryParams.email" placeholder="请输入邮箱" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" v-loading="loading" height="400" highlight-current-row @current-change="handleCurrentChange">
      <el-table-column label="编辑ID" prop="userId" align="center">
        <template slot-scope="scope">
          <el-radio name="userId" :label="scope.row.userId" @change="handleCurrentChange(scope.row)"
            v-model="userId"></el-radio>

        </template>
      </el-table-column>
      <el-table-column label="姓名" prop="nickName" align="center"></el-table-column>
      <el-table-column label="手机号" prop="phonenumber" align="center"></el-table-column>
      <el-table-column label="邮箱" prop="email" align="center"></el-table-column>
      <el-table-column label="科藤备注" prop="remark" align="center"></el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" :page-sizes="[10, 20, 30, 40,50]" />
    <div slot="footer" class="dialog-footer center">
      <el-button type="primary" v-hasPermi="['finance:change:money']" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { listPerson } from '@/api/order/process';

export default {
  props: {
    visibleDialog: {
      type: Boolean,
      default: false
    },
    alreadySelectProcessd: {
      type: Number,
      default: 0
    }
  },

  data() {
    return {
      localVisibleDialog: this.visibleDialog,
      loading: false,
      list: [],
      userId: 0,
      total: 0,
      row: {},
      showSearch: true,
      selected: 0,// 已选择的
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        userName: null,
        phonenumber: null,
        email: null,
        userId: null,
        nickName: null
      },
      isSearch: false
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    handleCurrentChange(val) {
      this.row = val;
      this.userId = val.userId
      console.log(val);
    },
    /**
     * 已选择
     * @param {{}} row 
     */
    handleSelectionChange(row) {
      this.row = row;
    },

    submitForm() {
      console.log("this.row", this.row);
      if (this.row.userId) {
        this.$emit('receiveProcess', this.row);
        this.$emit('close', false);
      } else {
        this.$message.error('请选择人员');
      }
    },

    getList() {
      listPerson(this.queryParams, this);
    },
    closeDialog() {
      this.$emit('close', false);
    },
    cancel() {
      this.$emit('close', false);
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.isSearch = true;
      this.getList();
    },
    resetQuery() {
      this.resetForm("queryForm");
      this.isSearch = false;
      this.queryParams.pageNum = 1;
      this.getList()
    }
  },
}
</script>

<style></style>
